home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / CRIBBAGE.PAK / CARDDISP.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  2KB  |  90 lines

  1. //--------------------------------------------------------------------------
  2. // Turbo Cribbage -- Copyright (c) 1995, Borland International
  3. //--------------------------------------------------------------------------
  4. #include <owl/pch.h>
  5. #include "carddisp.h"
  6. #include <owl/gdiobjec.h>
  7.  
  8. DEFINE_RESPONSE_TABLE1(TCardDisplay, TWindow)
  9.   EV_MESSAGE(WM_VBXFIREEVENT, VBXEventHandler),
  10. END_RESPONSE_TABLE;
  11.  
  12. TCardDisplay::TCardDisplay(TWindow* parent, int aId, int x, int y, int w, int h,
  13.                           int aBorderSize, int aMaxCards, TPoint *cardPositions,
  14.                           BOOL aRectangle, const char *aLabel,
  15.                           TPoint aLabelPos)
  16. :
  17.   TWindow(parent, "", 0), TCardGroup(aMaxCards)
  18. {
  19.  
  20.   Attr.Style = WS_CHILD | WS_VISIBLE;
  21.   Attr.X = x;
  22.   Attr.Y = y;
  23.   Attr.W = w;
  24.   Attr.H = h;
  25.   rectangle=aRectangle;
  26.   labelPos = aLabelPos;
  27.   id = aId;
  28.  
  29.   if (aLabel) {
  30.     strncpy(label,aLabel,20);
  31.     label[19]=0;
  32.   }
  33.   else
  34.     label[0]=0;
  35.  
  36.   borderSize=aBorderSize;
  37.   cardPos = new TPoint[GetMaxCards()];
  38.   for (int i = 0; i < GetMaxCards(); i++)
  39.     cardPos[i] = cardPositions[i];
  40.   cardvbx= new TVbxMhCardDeck*[GetMaxCards()];
  41.  
  42.   for (int i=GetMaxCards()-1;i>=0;i--)
  43.     cardvbx[i] = new TVbxMhCardDeck(this, i, "",
  44.                                      cardPos[i].x, cardPos[i].y,
  45.                                      71, 95);
  46. }
  47.  
  48. void TCardDisplay::SetupWindow()
  49. {
  50.   TWindow::SetupWindow();
  51.  
  52.   SetBkgndColor(TColor(0, 128, 0));
  53.  
  54.   for (int i = 0; i < GetMaxCards(); i++) {
  55.     cardvbx[i]->ShowWindow(SW_HIDE);
  56.     cardvbx[i]->SetPropBackColor(TColor(0, 128, 0));
  57.   }
  58. }
  59.  
  60. void TCardDisplay::Paint(TDC& dc, bool, TRect&)
  61. {
  62.   if (rectangle) {
  63.     TRect temp = GetClientRect();
  64.     temp.left += borderSize;
  65.     temp.top += borderSize;
  66.     temp.right -= borderSize;
  67.     temp.bottom -= borderSize;
  68.     dc.SelectObject(TPen(TColor(0, 255, 0)));
  69.     dc.SelectObject(TBrush(TColor(0, 128, 0)));
  70.     dc.RoundRect(temp, TPoint(10,10));
  71.   }
  72.   dc.SetTextColor(TColor(0, 255, 0));
  73.   dc.SetBkColor(TColor(0, 128, 0));
  74.   dc.TextOut(labelPos, label);
  75. }
  76.  
  77. TCard* TCardDisplay::Remove(int pos)
  78. {
  79.   TCard* temp = TCardGroup::Remove(pos);
  80.   cardvbx[pos]->ShowWindow(SW_HIDE);
  81.  
  82.   for (int i = 0; i < GetMaxCards(); i++) {
  83.     if (i < GetCount() )
  84.       Show(i, cards[i]);
  85.     else
  86.       cardvbx[i]->ShowWindow(SW_HIDE);
  87.   }
  88.   return temp;
  89. }
  90.